/**
 * @author Tin Pham / 7inpham@gmail.com
 */
 
Tinz.RoomWorld = function() {
	THREE.Scene.call(this);
	var that = this;
	// LIGHTS
	var ambient = new THREE.AmbientLight(0xeeeeee);
	this.add(ambient);
	this.fog = new THREE.Fog(0x34583e, 0, 10000);
	var height = 128;
	// Set the different geometries composing the room
	var plane = new THREE.PlaneGeometry(512, 1024);
	var walls = [
		new THREE.PlaneGeometry(plane.parameters.height, height),
		new THREE.PlaneGeometry(plane.parameters.width, height),
		new THREE.PlaneGeometry(plane.parameters.height, height),
		new THREE.PlaneGeometry(plane.parameters.width, height)
	];
	var obstacles = [
		new THREE.BoxGeometry(64, 64, 64)
	];
	// Set the material, the "skin"
	var material = new THREE.MeshBasicMaterial({wireframe: true, color: 0x0033ff});
	//var material = new THREE.MeshPhongMaterial({ambient: 0x050505, color: 0x0033ff, specular: 0x555555, shininess: 30});
	// Set and add the ground
	this.ground = new THREE.Mesh(plane, material);
	this.ground.rotation.x = -Math.PI / 2;
	this.add(this.ground);
	// Set and add the walls
	this.walls = [];
	for (var i = 0; i < walls.length; i += 1) {
		this.walls[i] = new THREE.Mesh(walls[i], material);
		this.walls[i].position.y = height / 2;
		this.add(this.walls[i]);
	}
	this.walls[0].rotation.y = -Math.PI / 2;
	this.walls[0].position.x = plane.parameters.width / 2;
	this.walls[1].rotation.y = Math.PI;
	this.walls[1].position.z = plane.parameters.height / 2;
	this.walls[2].rotation.y = Math.PI / 2;
	this.walls[2].position.x = -plane.parameters.width / 2;
	this.walls[3].position.z = -plane.parameters.height / 2;
	// Set and add the obstacles
	this.obstacles = [];
	for (var i = 0; i < obstacles.length; i += 1) {
		this.obstacles[i] = new THREE.Mesh(obstacles[i], material);
		this.add(this.obstacles[i]);
	}
	this.obstacles[0].position.set(10, 32, 128);
};

Tinz.RoomWorld.prototype = Object.create(THREE.Scene.prototype);

Tinz.RoomWorld.prototype.getObstacles = function() {
	return this.obstacles.concat(this.walls);
};
